<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="../lib/ext/resources/css/ext-all-neptune.css"/>
    <script type="text/javascript" src="../lib/ext/ext-all.js"></script>
    <script type="text/javascript" src="../lib/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="../lib/ext_ux_ckeditor.js"></script>
    <script type="text/javascript" src="../lib/gf/common_grid.js"></script>
</head>
<script type="text/javascript">
    Ext.Loader.setConfig({enabled: true});
    var dataForm;
    var data = {};

    var fileform = Ext.create('Ext.form.Panel', {
        title: 'Upload a Photo',
        width: 400,
        bodyPadding: 10,
        frame: true,
        items: [{
            xtype: 'filefield',
            name: 'photo',
            fieldLabel: 'Photo',
            labelWidth: 50,
            msgTarget: 'side',
            allowBlank: false,
            anchor: '100%',
            buttonText: 'Select Photo...'
        }],

        buttons: [{
            text: 'Upload',
            handler: function() {
                var form = this.up('form').getForm();
                if (form.isValid()) {
                    form.submit({
                        url: 'photo-upload.php',
                        waitMsg: 'Uploading your photo...',
                        success: function(fp, o) {
                            Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
                        }
                    });
                }
            }
        }]
    });
    function uploadFile() {
        alert("abcd");
        fileform.show();
    }

    Ext.onReady(function () {
        //保存数据
        function doAdd(){
            uploadFile();
            
        }
        //关闭窗口
        function doClose(){
            parent.closeWin();
        }
        var tbar = [
            {pressed: true,text: '保  存',handler: doAdd,icon : '../img/book.png'},
            {pressed: true,text: "关  闭",handler: doClose,icon : '../img/close.png'}
        ];
        dataForm = new Ext.FormPanel({
            layout : 'fit',
            items : [
                {
                    tbar : tbar
                }
            ]            
        });
        var viewport = new Ext.Viewport({
            layout: 'fit',
            renderTo: "mypanel",
            items: [dataForm]
        });
        

        function init_form(){            
        }
    });
</script>
<body>
<div id="mypanel"></div>
</body>
</html>